import lookUp from "./lookUp";
import parseArray from "./parseArray";
// 让tokens数组变为dom字符串
export default function renderTemplate(tokens, data) {
    // 结果字符串
    var resultStr = "";
    // 遍历tokens
    for (let i = 0; i < tokens.length; i++) {
        let token = tokens[i];
        // 判断类型
        if (token[0] == "text") {
            resultStr += token[1];
        } else if (token[0] == "name") {
            resultStr += lookUp(data, token[1]);
        } else if (token[0] == "#") {
            resultStr += parseArray(token, data);
        }
    }
    return resultStr;
}